﻿using System;
using System.Collections.Generic;

namespace TaskBoardProject.TaskComparers
{
    /// <summary>
    /// Comparer by project name
    /// </summary>
    public class TaskProjectNameComparer : IComparer <Task>
    {
        /// <summary>
        /// Compare two tasks by project name
        /// </summary>
        /// <param name="firstTask">first task</param>
        /// <param name="secondTask">second task</param>
        /// <returns>result of comparing</returns>
        public int Compare(Task firstTask, Task secondTask)
        {
            // Check if parameters are null
            if (firstTask == null && secondTask == null)
                return 0;
            else if (secondTask == null)
                return 1;
            else if (firstTask == null)
                return -1;
            else
                // Compare by projectName
                return firstTask.ProjectName.CompareTo(secondTask.ProjectName);
        }
    }
}
